<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>级联数据列表</title>

    <link href="/Application/Admin/Public/css/base.css" rel="stylesheet">
    <link rel="stylesheet" href="/Application/Admin/Public/custom/uimaker/easyui.css">
    <link rel="stylesheet" type="text/css" href="/Application/Admin/Public/custom/uimaker/icon.css">
    <link rel="stylesheet" href="/Application/Admin/Public/css/providers.css">
    <style type="text/css">
        .summary {
            border: 1px solid #ccc;
            border-top: #1da02b 1px solid;
            padding: 8px;
        }
        .summary form >div{
            margin-top: 20px;
           /* display: inline-block;
            width: 49%;*/
        }
        .summary label{
            width: 100px;
            text-align: right;
            display: inline-block;
            margin-right: 20px;
        }

        .addimg{
          margin-right: 10px;
        }
        .pic ul{
          margin: 10px 24px;
        }
        .pic li{
          list-style: none;
          float: left;
          position: relative;
          margin: 10px 5px;
          border-radius: 5px;
          overflow: hidden;
          height: 100px;
          transition: 0.5s;
        }
        .pic li:hover{
          box-shadow: 1px 1px 15px 3px #333;
          transition: 0.5s
        }
        .pic li:hover .del{
          display: block;
        }
        .del{
          position: absolute;height: 20px;width: 20px;border-radius: 10px;background: #fff;border:1px solid #333;right: 0px;top: 0px;text-align: center;line-height: 20px;cursor: pointer;display: none;
        }
        .minp{height: 24px;border:1px solid #aaa;text-indent: 5px}
        hr{background: #5bbc9a;border: 0;height: 1px;margin: 30px 30px 0;}
        /*.onel{display:inline-block;width:30%;}*/
        .onel img{margin:10px 30px;}
        .binfo li{list-style: none;float: left;width: 40%;}
        .binfo li div{margin-top: 20px;}

        .binfo2 li{list-style: none;float: left;width: 30%;}
        .binfo2 li div{margin-top: 20px;}


        .myImg {
            border-radius: 5px;
            cursor: pointer;
            transition: 0.3s;
        }

        .myImg:hover {opacity: 0.7;}

        .modal {
            display: none;
            position: fixed;
            z-index: 1;
            padding-top: 100px;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            overflow: auto;
            background-color: rgb(0,0,0);
            background-color: rgba(0,0,0,0.7);
        }

        .modal-content {
            margin: auto;
            display: block;
            /*width: 100%;*/
            max-width: 600px;
        }

        #caption {
            margin: auto;
            display: block;
            width: 80%;
            max-width: 700px;
            text-align: center;
            color: #ccc;
            padding: 10px 0;
            height: 150px;
        }

        .modal-content, #caption {
            -webkit-animation-name: zoom;
            -webkit-animation-duration: 0.6s;
            animation-name: zoom;
            animation-duration: 0.6s;
        }

        @-webkit-keyframes zoom {
            from {-webkit-transform: scale(0)}
            to {-webkit-transform: scale(1)}
        }

        @keyframes zoom {
            from {transform: scale(0.1)}
            to {transform: scale(1)}
        }

        .close {
            /*position: absolute;*/
            top: 0px;
            right: 35px;
            color: #f1f1f1;
            font-size: 40px;
            font-weight: bold;
            transition: 0.3s;
        }

        .close:hover,
        .close:focus {
            color: #bbb;
            text-decoration: none;
            cursor: pointer;
        }

        @media only screen and (max-width: 700px){
            .modal-content {
                width: 100%;
            }
        }


    </style>

</head>
<body>




<div class="container" style="padding:10px 30px;">
    <!-- <a href="<?php echo U('Game/index');?>" class="easyui-linkbutton" iconCls="icon-back" >返回</a> -->
    <a href="javascript:" onclick="self.location=document.referrer;" class="easyui-linkbutton" iconCls="icon-back">返回</a>
</div>


<div class="contractinfo-table">

    <div id="myModal" class="modal close">
        <!--<span >×</span>-->
        <img class="modal-content" id="imgInfo">
        <div id="caption"></div>
    </div>


    <div class="summary">
    

  <!--   <form id="addpic" method="post" novalidate="novalidate" action='<?php echo U("Game/addImg");?>' enctype="multipart/form-data" style='margin-top: 30px;'>
         <button type="submit">tijao</button> -->
     <form id="addpic" method="post" novalidate="novalidate" enctype="multipart/form-data" style='margin-top: 30px;'>
         <input type="hidden" id="action" name="action">
        <input type="hidden" value="<?php echo ($data["gameid"]); ?>" name='gameid'></input>

         <div class="binfo">
             <ul>
                <li style="border-right: 1px solid #5bbc9a">
                <div><label>游戏名称:</label><input value="<?php echo ($data["game"]); ?>" type='text' name='game' class='easyui-textbox minp' data-options="required:true"  style="height:28px" /></div>
                <!-- <div><label>说明:</label><input  class= 'easyui-textbox minp' value="<?php echo ($data["description"]); ?>" type='text' name='description' data-options="required:true" class="easyui-textbox" style="height:28px" /></div> -->
                 <div><label>排序:</label><input class="easyui-numberspinner minp" value="<?php echo ($data["orderid"]); ?>" name="orderid" data-options="increment:1,required:true" style="height:30px;"></div>
                  <div><label>联运平台ID:</label><input  class= 'easyui-textbox minp' value="<?php echo ($data["lyptid"]); ?>" type='text' name='lyptid' data-options="required:true" class="easyui-textbox" style="height:28px" /></div>

                 </li>
                 <li>
                  <div><label>应用ID:</label>
                      <select  name="appid"  style="width: 153px;height: 30px;">
                          <option value="" selected>请选择</option>
                            <?php if(is_array($app_id)): $i = 0; $__LIST__ = $app_id;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if($vo["appid"] == $data[appid]): ?><option value="<?php echo ($vo["appid"]); ?>" selected>ID:<?php echo ($vo["appid"]); ?>,<?php echo ($vo["app"]); ?></option>
                                    <?php else: ?>  
                                  <option value="<?php echo ($vo["appid"]); ?>">ID:<?php echo ($vo["appid"]); ?>,<?php echo ($vo["app"]); ?></option><?php endif; endforeach; endif; else: echo "" ;endif; ?> 
                      </select>
                    </div>
                    <div><label>类型编号:</label>
                        <select name="typecode" required='true' style="width: 153px;height: 30px;">
                            <option value="" selected>请选择</option>
                            <?php if(is_array($type_id)): $i = 0; $__LIST__ = $type_id;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if($vo["typeid"] == $data[typecode]): ?><option value="<?php echo ($vo["typeid"]); ?>" selected>ID:<?php echo ($vo["typeid"]); ?>,<?php echo ($vo["type"]); ?></option>
                                  <?php else: ?>  
                                <option value="<?php echo ($vo["typeid"]); ?>">ID:<?php echo ($vo["typeid"]); ?>,<?php echo ($vo["type"]); ?></option><?php endif; endforeach; endif; else: echo "" ;endif; ?> 
                        </select>
                    </div>

                 </li>
                 <div style="clear: both;"></div>
             </ul>
         </div>

         <hr/>
          <div class="diqu">
            <label>区域编号:</label>
            <input  class='minp' id='test' value="<?php echo ($data["areacode"]); ?>" type='text' name='areacode' readonly="readonly" style="height:28px" />
            <span><?php echo ($sheng["area"]); ?></span>  <span><?php echo ($shi["area"]); ?></span>  <span><?php echo ($data["area"]); ?></span>
          </div>
          <div><label>修改区域:</label>
              <select  id="province_id" style="width:153px;height: 30px;" >
                  <option>请选择</option>
                  <?php if(is_array($province_list)): $i = 0; $__LIST__ = $province_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$province): $mod = ($i % 2 );++$i;?><option  value="<?php echo ($province["areacode"]); ?>"><?php echo ($province["area"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>                                                  
              </select>
                
              <select  id="city_id" style="width:153px;height: 30px;">
                  <?php if(is_array($city_list)): $i = 0; $__LIST__ = $city_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$city): $mod = ($i % 2 );++$i;?><option value="<?php echo ($city["areacode"]); ?>" selected="selected"><?php echo ($city["area"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>                                                  
              </select>
                 
              <select id="district_id" style="width:153px;height: 30px;">
                  <?php if(is_array($dis_list)): $i = 0; $__LIST__ = $dis_list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$dis): $mod = ($i % 2 );++$i;?><option value="{$dis.areacode}" selected="selected">{$dis.area}</option><?php endforeach; endif; else: echo "" ;endif; ?>                                              
              </select> 
          </div>
          <div><label>属性:</label>
              <?php if(is_array($flag)): $i = 0; $__LIST__ = $flag;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if(in_array(($vo["datavalue"]), is_array($data[flag])?$data[flag]:explode(',',$data[flag]))): ?><input type="checkbox" name="flag[]" checked="checked" value="<?php echo ($vo["datavalue"]); ?>"><?php echo ($vo["dataname"]); ?> [<?php echo ($vo["datavalue"]); ?>]
                        <?php else: ?>
                        <input type="checkbox" name="flag[]"  value="<?php echo ($vo["datavalue"]); ?>"><?php echo ($vo["dataname"]); ?> [<?php echo ($vo["datavalue"]); ?>]<?php endif; endforeach; endif; else: echo "" ;endif; ?> 
          </div>

          <hr/>

            <div class="binfo">
            <ul>
             <?php if(!empty($data["gameid"])): ?><li style="border-right: 1px solid #5bbc9a">
                <div><label>游戏ID:</label><span><?php echo ($data["gameid"]); ?></span></div>
                <div><label>操作人:</label><span><?php echo ($data["admin"]); ?></span></div>
                <div><label>创建时间:</label><span><?php echo ($data["createtime"]); ?></span></div>
                <div><label>修改时间:</label><span><?php echo ($data["updatetime"]); ?></span></div>
                <div><label>ID:</label><span><?php echo ($data["id"]); ?></span></div>
                </li><?php endif; ?>
              <li>
                <div><label>游戏说明:</label>
                <input class="easyui-textbox" data-options="multiline:true" value="<?php echo ($data["description"]); ?>" name='description' style="width:300px;height:100px">
                </div>
                </li>
                <div style="clear: both;"></div>
                </ul>
             </div>

          <hr/>

          <div class="pic">
              <label>游戏图组：</label>
              <ul>
                  <?php if(is_array($datap["picarr"])): $k = 0; $__LIST__ = $datap["picarr"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($k % 2 );++$k;?><li class="picli-<?php echo ($k); ?>">
                          <input type="hidden" value="<?php echo ($vo); ?>" name='picarr[]'>

                          <a href="javascript:void(0)" onclick = "imdBig()"> 

                          <img class='myImg'  style="height: 100px;" src ='<?php echo C("WEBHOME"); echo ($vo); ?>'>

                          </a>
                          <div class="del">X</div>

                      </li><?php endforeach; endif; else: echo "" ;endif; ?>

                  <div style="clear: both;"></div>
              </ul>
          </div>

          <div><label>上传图片:</label>
            <input id="fb1" class="easyui-filebox"name="picarr[]" style="width:150px" data-options="label:'图片上传',prompt:'选择图片',onChange:function(){lookImg(1)}" multiple>
            <div style="margin:24px"id="addImage1"></div>
          </div>

          
          <hr/>

         <div class="binfo2">
             <ul>
                 <li style="border-right: 1px solid #5bbc9a">

          <div class="pic onel">
              <label>游戏图标:</label><br/>
              <input class="iconimg" type="hidden" value="<?php echo ($data["icon"]); ?>" name='icon[]'>
              <?php if(!empty($data["icon"])): ?><a href="javascript:void(0)" onclick = "imdBig()"> <img class='myImg' style="height: 100px;" src ='<?php echo C("WEBHOME"); echo ($data["icon"]); ?>'></a><?php endif; ?>
              <div style="clear: both;"></div>
          </div>

          <div><label>上传图片:</label>
            <input id="fb2" class="easyui-filebox" name="icon[]" style="width:150px" data-options="label:'图片上传',prompt:'选择图片',onChange:function(){lookImg(2)}">
            <div style="margin:24px" id="addImage2"></div>
          </div>

                 </li>
                 <li style="border-right: 1px solid #5bbc9a">

          <div class="pic onel">
              <label>海报首页推荐:</label><br/>
                  <input class="poimg" type="hidden" value="<?php echo ($data["poster"]); ?>" name='poster[]'>
                  <?php if(!empty($data["poster"])): ?><a href="javascript:void(0)" onclick = "imdBig()"> <img class='myImg' style="height: 100px;" src ='<?php echo C("WEBHOME"); echo ($data["poster"]); ?>'></a>
                  <!-- <img style="height: 100px;"   class="poimg" src="<?php echo ($data["poster"]); ?>"> --><?php endif; ?>
                  <div style="clear: both;"></div>
          </div>

          <div><label>上传图片:</label>
            <input id="fb3" class="easyui-filebox"name="poster[]" style="width:150px" data-options="label:'图片上传',prompt:'选择图片',onChange:function(){lookImg(3)}" >
            <div style="margin:24px"id="addImage3"></div>
          </div>

                 </li>
                 <li>
          <div class="pic onel">
              <label>特别推荐:</label><br/>
                    <input class="adimg" type="hidden" value="<?php echo ($data["adpic"]); ?>" name='adpic[]'>
                    <?php if(!empty($data["adpic"])): ?><a href="javascript:void(0)" onclick = "imdBig()"> <img class='myImg' style="height: 100px;" src ='<?php echo C("WEBHOME"); echo ($data["adpic"]); ?>'></a>

                    <!-- <img  class="adimg"style="height: 100px;"  src="<?php echo ($data["adpic"]); ?>"> --><?php endif; ?>
                  <div style="clear: both;"></div>
          </div>

          <div><label>上传图片:</label>
            <input id="fb4" class="easyui-filebox" name="adpic[]" style="width:150px" data-options="label:'图片上传',prompt:'选择图片',onChange:function(){lookImg(4)}" >

            <div style="margin:24px"id="addImage4"></div>
          </div>

                 </li>
                 <div style="clear: both;"></div>
             </ul>

         </div>
    </form>
    
    <hr/>
    <div id="dlg-buttons">
      <a style="margin: 10px 50px;" href="javascript:void(0)" class="easyui-linkbutton" id="btnAddOK" iconcls="icon-ok" onclick="btnAddOK()">保存</a>
    </div>
  </div>

</div>




<script type="text/javascript" src="/Application/Admin/Public/custom/jquery.min.js"></script>
<script type="text/javascript" src="/Application/Admin/Public/custom/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/Application/Admin/Public/custom/easyui-lang-zh_CN.js"></script>
<script>

$("input").blur(function(){
  $(this).css("border","#aaa solid 1px");
});

$("input").focus(function(){
  $(this).css("border","#1da02b  solid 1.5px");
});

  function btnAddOK() {
        $('#addpic').form('submit',{
            url: '<?php echo U("Game/addImg");?>',
            onSubmit: function(){
                return $(this).form('validate');

            },
            success: function(result){
              if(result>0){
                if(result==1){
                    $.messager.alert('提示','修改成功!','info',function(){
                          reload();
                      });
                }else{
                   $.messager.confirm('提示', '添加成功，继续添加?', function(r){
                      if (r){
                          reload();
                      }else{
                         window.location.href='<?php echo U("Game/index");?>'; 
                      }
                  });
                }  

              }else{
                $.messager.show({
                    title: '错误提示',
                    msg: '操作失败'
                });
              }
            }
        });
    }



                       






    $('.del').click(function(){
        $(this).parent().remove();
    })

    // 上传图片预览
    function lookImg(x){
      if(x==2){
        $('.iconimg').remove();
      }else if(x==3){
        $('.poimg').remove();
      }else if(x==4){
        $('.adimg').remove();
      }
      var dd = 'aaa'+x;
        var dd = $("#fb"+x).next().find('input[type=file]')[0];
        if (dd.files && dd.files[0]){
          // 更换图片时清空原图片展示内容
            $('#addImage'+x).html('');
             for(var i=0;i<dd.files.length;i++){
                var reader = new FileReader(dd.files[i]);
                reader.onload = function(e){
            //append为在元素中的末尾添加内容
                    $('#addImage'+x).append("<img class='addimg' src='"+e.target.result+"'height='50px;'/>");
                }
                reader.readAsDataURL(dd.files[i]);
             }
        }
    }


    // 省市县三级联动
    $("#province_id").change(function(){
      $('.diqu span').hide();
      var shengcode=$(this).val();
      var sheng = shengcode.substr(0,2);
      if(sheng == 71|sheng == 81|sheng == 82){
          $('#city_id,#district_id').hide();
          $("#test").val(shengcode);
      }else{
        $('#city_id,#district_id').show();
          if(sheng == 11|sheng == 12|sheng == 31|sheng == 50){
            $.ajax({
            url:'<?php echo U("Game/xian");?>',
            data:{
              xian:sheng,
            },
            dataType:"json",
            success:function(data){
              $('#city_id').hide();
              var district = data.district;
              var option=$("<option></option>");
              $(option).val("0");
              $(option).html("请选择");
              $("#district_id").html(option);
              for(var i in district){
                var option=$("<option></option>");
                $(option).val(district[i]['areacode']);
                $(option).html(district[i]['area']);
                $("#district_id").append(option);
              }
            }
          });
        }else{
            $.ajax({
            url:'<?php echo U("Game/shi");?>',
            data:{
              sheng:sheng,
            },
            dataType:"json",
            success:function(data){
              $('#city_id').show();
              var city = data.city;
              var option=$("<option></option>");
              $(option).val("0");
              $(option).html("请选择");
              var option1=$("<option></option>");
              $(option1).val("0");
              $(option1).html("请选择");
              $("#city_id").html(option);
              $("#district_id").html(option1);
              for(var i in city){
                var option=$("<option></option>");
                $(option).val(city[i]['areacode']);
                $(option).html(city[i]['area']);
                $("#city_id").append(option);
              }
            }
          });
        }
      }

    });

    $("#city_id").change(function(){
      var shicode=$(this).val();
      $('input[name="areacode"]').val();
      var xian = shicode.substr(0,4);
      $.ajax({
        url:'<?php echo U("Game/xian");?>',
        data:{
          xian:xian,
        },
        dataType:"json",
        success:function(data){
          var district = data.district;
          var option=$("<option></option>");
          $(option).val("0");
          $(option).html("请选择");
          $("#district_id").html(option);
          for(var i in district){
            var option=$("<option></option>");
            $(option).val(district[i]['areacode']);
            $(option).html(district[i]['area']);
            $("#district_id").append(option);
          }
        }
      });
    });

    $("#district_id").change(function(){
      var xiancode=$(this).val();
      $("#test").val(xiancode);
    });

     function reload(){
        window.location.reload();
    }

/**
 * 点击设置图片放大
 */
function imdBig() {

    var modal = document.getElementById('myModal');
    var modalImg = document.getElementById("imgInfo");
    var captionText = document.getElementById("caption");
    $(".myImg").on("click",function(){
        modal.style.display = "block";
        modalImg.src = this.src;
        modalImg.alt = this.alt;
        captionText.innerHTML = this.alt;
    });
    var span = document.getElementsByClassName("close")[0];
    span.onclick = function() {
        modal.style.display = "none";
    }
}



</script>
</body>
</html>